<%
# Copyright (C) 2011 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
%>

<%
  css_bundle :quizzes
  js_bundle :quizzes_bundle
  js_env :QUIZZES => {:QUIZ => true}
  content_for :page_title, (@quiz.quiz_title || !@quiz.quiz_title.empty? ? @quiz.quiz_title : t(:default_page_title, 'New Quiz'))
%>
<% content_for :right_side do %>
  <a href="<%= context_url(@context, :context_quiz_url, @quiz.id) %>" class="btn button-sidebar-wide">
    {{> icons/arrow-left}}
    {{#t}}Back to Quiz Page{{/t}}
  </a>
<% end %>


<h2>{{#t}}Quiz Details{{/t}}</h2>
<div style="display: none;" id="quiz_urls">
  <a href="<%= context_url(@context, :context_quiz_url, @quiz.id) %>" class="update_quiz_url">&nbsp;</a>
  <a href="<%= context_url(@context, :context_quiz_quiz_questions_url, @quiz.id) %>" class="add_question_url">&nbsp;</a>
  <a href="<%= context_url(@context, :api_v1_context_quiz_reorder_url, @quiz.id) %>" class="reorder_questions_url">&nbsp;</a>
  <a href="<%= context_url(@context, :context_quiz_quiz_groups_url, @quiz.id) %>" class="add_group_url">&nbsp;</a>
</div>


<div style="margin-bottom: 25px;">
  <%= before_label(:quiz_instructions, "Quiz Instructions") %>
  <%= user_content(@quiz.description, @context.asset_string) %>
</div>
<div style="margin-bottom: 5px;">
  <input type="checkbox" id="show_question_details"/> <label for="show_question_details">{{#t}}Show Question Details{{/t}}</label>
</div>
<div id="questions" class="brief">
  <% @quiz.root_entries.each do |question| %>
    <% if question[:entry_type] == "quiz_group" %>
      {{> views/question_group}}
    <% else %>
      <%= render :partial => (@quiz.active_quiz_questions.size > 25 ? "question_teaser" : "display_question"), :object => question, :locals => {:editing => true, :asset_string => "quiz_question_#{question['id']}"} %>
    <% end %>
  <% end %>
</div>
<% content_for :stylesheets do %>
<style>
#questions .question_holder .display_question .move {
  display: none;
}
#questions .question_holder .display_question .links {
  display: none;
}
#questions .group_top .quiz_group_form .links {
  display: none;
}

</style>
<% end %>

{{> views/question_teaser}}
{{> views/display_question}}
{{> views/display_answer}}
{{> views/form_answer}}
{{> views/form_question}}
{{> views/question_group}}
{{> views/find_question_from_bank}}
